var xmlHttp

function checkUser(str) {
	xmlHttp = GetXmlHttpObject()

	if (xmlHttp == null) {
		alert("您的浏览器不支持AJAX！");
		return;
	}

	var url = "UserCheckServlet?username=" + str;
	xmlHttp.onreadystatechange = function stateChanged() {
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200) {
				document.getElementById("msg").innerHTML = xmlHttp.responseText;
			}else{
				alert("HTTP error" + xmlHttp.status);
			}
		}
	};
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

function GetXmlHttpObject() {
	 var xmlHttp;          
     if (window.XMLHttpRequest) {//分浏览器创建XMLHttp对象  
         xmlHttp = new XMLHttpRequest();  
     } else if (window.ActiveXObject) {  
         xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  
     }   
	return xmlHttp;
}